<div class="dialog">
    <table>
        <tbody>

            <tr class="prop">
                <td valign="top" class="name">
                    <label for="serialNumber"><g:message code="pickplan.serialNumber" default="Serial Number" />:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: pickplanInstance, field: 'serialNumber', 'errors')}">
                    <g:textField name="serialNumber" value="${fieldValue(bean: pickplanInstance, field: 'serialNumber')}" />
                </td>
       
                <td valign="top" class="name">
                    <label for="date"><g:message code="pickplan.date" default="Date" />:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: pickplanInstance, field: 'date', 'errors')}">
                    <g:jqDatePicker name="date" value="${pickplanInstance?.date}"></g:jqDatePicker>
                </td>
        
                <td valign="top" class="name">
                    <label for="maker"><g:message code="pickplan.maker" default="Maker" />:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: pickplanInstance, field: 'maker', 'errors')}">
                    <g:textField name="makerInput" value="${pickplanInstance?.maker?.encodeAsHTML()}"/>
                    <g:hiddenField name="maker.id" value="${pickplanInstance?.maker?.id}" />
                </td>
            </tr>
        
            <tr class="prop">
                <td valign="top" class="name">
                    <label for="dealer">&nbsp;</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: pickplanInstance, field: 'dealer', 'errors')}">
                    &nbsp;
                </td>
        
                <td valign="top" class="name">
                    <label for="director"><g:message code="pickplan.director" default="Director" />:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: pickplanInstance, field: 'director', 'errors')}">
                    <g:textField name="directorInput" value="${pickplanInstance?.director?.encodeAsHTML()}"/>
                    <g:hiddenField name="director.id" value="${pickplanInstance?.director?.id}" />
                 </td>
        
                <td valign="top" class="name">
                    <label for="recordType"><g:message code="pickplan.recordType" default="Record Type" />:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: pickplanInstance, field: 'recordType', 'errors')}">
                    ${pickplanInstance?.recordType?.encodeAsHTML()}
                    <g:hiddenField name="recordType.id" value="${pickplanInstance?.recordType?.id}" />
                </td>
            </tr>
        
        </tbody>
    </table>
</div>
<div class="list">
    <table>
        <thead>
            <tr>
                <th><g:message code="pickplanDetail.serialNumber" default="Serial Number" /></th>
                <th><g:message code="pickplanDetail.product" default="Product" /></th>
                <th><g:message code="pickplanDetail.unit" default="Unit" /></th>
                <th><g:message code="pickplanDetail.dealer" default="Dealer" /></th>
                <th class="number"><g:message code="pickplanDetail.quantity" default="Quantity" /></th>
                <th class="number"><g:message code="pickplanDetail.price" default="Price" /></th>
                <th class="number"><g:message code="pickplanDetail.amount" default="Amount" /></th>
             </tr>
        </thead>
        <tbody>
        <g:each in="${pickplanInstance?.details?.sort{it?.serialNumber}}" status="i" var="pickplanDetailInstance">
            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                <td>
                    ${fieldValue(bean: pickplanDetailInstance, field: "serialNumber")}
                    <g:hiddenField name="details[${i}].serialNumber" value="${pickplanDetailInstance?.serialNumber}" />
                </td>
                <td>
                    ${fieldValue(bean: pickplanDetailInstance, field: "product")}
                    <g:hiddenField name="details[${i}].product.id" value="${pickplanDetailInstance?.product?.id}" />
                </td>
                <td>
                    ${fieldValue(bean: pickplanDetailInstance, field: "unit")}
                    <g:hiddenField name="details[${i}].unit" value="${pickplanDetailInstance?.unit}" />
                </td>
                <td class="${hasErrors(bean: pickplanInstance, field: 'dealer', 'errors')}">
                    <g:textField name="details[${i}].dealerInput" value="${pickplanDetailInstance?.dealer?.encodeAsHTML()}"/>
                    <g:hiddenField name="details[${i}].dealer.id" value="${pickplanDetailInstance?.dealer?.id}" />
                </td>
                <td class="number ${hasErrors(bean: pickplanInstance, field: 'quantity', 'errors')}">
                    <g:textField name="details[${i}].quantity" value="${formatNumber(number : pickplanDetailInstance?.quantity, format : '###,##0.00')}"/>
                </td>
                <td class="number ${hasErrors(bean: pickplanInstance, field: 'price', 'errors')}">
                    <g:textField name="details[${i}].price" value="${formatNumber(number : pickplanDetailInstance?.price, format : '###,##0.00')}"/>
                </td>
                <td class="number ${hasErrors(bean: pickplanInstance, field: 'amount', 'errors')}">
                    <span name="details[${i}].amount">
                        ${formatNumber(number : pickplanDetailInstance?.amount, format : '###,##0.00')}
                    </span>
                    <g:hiddenField name="details[${i}].amount" value="${formatNumber(number : pickplanDetailInstance?.amount, format : '###,##0.00')}"/>
                </td>
             </tr>
        </g:each>
        </tbody>
    </table>
</div>

